﻿using UnityEngine;

public class ManagerUI {
	// === Public =====================================================================================================
	public static ManagerUI CreateInstance() {
		return new ManagerUI();
	}

	public Texture2D GetBackgroundNormal(string name) {
		Texture2D bg = null;
		if (typeof(UIMenuBar).ToString().Equals(name) || typeof(UIListView).ToString().Equals(name)) {
			bg = _bgMenuBarNormal;
		} else if (typeof(UIMenuItem).ToString().Equals(name) || typeof(UIListItem).ToString().Equals(name)) {
			bg = _bgButtonNormal;
		}
		return bg;
	}

	public Texture2D GetBackgroundHover(string name) {
		Texture2D bg = null;
		if (typeof(UIMenuBar).ToString().Equals(name) || typeof(UIListView).ToString().Equals(name)) {
			bg = _bgMenuBarNormal;
		} else if (typeof(UIMenuItem).ToString().Equals(name) || typeof(UIListItem).ToString().Equals(name)) {
			bg = _bgButtonHover;
		}
		return bg;
	}

	public Texture2D GetBackgroundActive(string name) {
		Texture2D bg = null;
		if (typeof(UIMenuBar).ToString().Equals(name) || typeof(UIListView).ToString().Equals(name)) {
			bg = _bgMenuBarNormal;
		} else if (typeof(UIMenuItem).ToString().Equals(name) || typeof(UIListItem).ToString().Equals(name)) {
			bg = _bgButtonActive;
		}
		return bg;
	}

	public Vector4 GetBackgroundBorder(string name) {
		var bgb = new Vector4(-1, -1, -1, -1);
		if (typeof(UIMenuBar).ToString().Equals(name) || typeof(UIListView).ToString().Equals(name)) {
			bgb = _bgbMenuBar;
		} else if (typeof(UIMenuItem).ToString().Equals(name) || typeof(UIListItem).ToString().Equals(name)) {
			bgb = _bgbButton;
		}
		return bgb;
	}

	// === Private ====================================================================================================
	private readonly Texture2D _bgMenuBarNormal;
	private readonly Vector4 _bgbMenuBar;

	private readonly Texture2D _bgButtonNormal;
	private readonly Texture2D _bgButtonHover;
	private readonly Texture2D _bgButtonActive;
	private readonly Vector4 _bgbButton;

	private ManagerUI() {
		_bgMenuBarNormal = Tools.Resources.GetObjectFromResources<Texture2D>(ResourceConstants.UI.Textures.BOX);
		_bgbMenuBar = new Vector4(5, 5, 5, 5);

		_bgButtonNormal = Tools.Resources.GetObjectFromResources<Texture2D>(ResourceConstants.UI.Textures.BUTTON_NORMAL);
		_bgButtonHover = Tools.Resources.GetObjectFromResources<Texture2D>(ResourceConstants.UI.Textures.BUTTON_HOVER);
		_bgButtonActive = Tools.Resources.GetObjectFromResources<Texture2D>(ResourceConstants.UI.Textures.BUTTON_ACTIVE);
		_bgbButton = new Vector4(2, 2, 2, 3);
	}
}
